VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ClsTipoPago"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Public WithEvents orset As ClsRecordset
Attribute orset.VB_VarHelpID = -1

Public Event DataChanged()

' Public members to implement properties
Public codigo As String
Public tipo As String
Public descripcion As String
Public documentos As Boolean

' Class event handlers
Private Sub Class_Initialize()
    Set orset = New ClsRecordset
    orset.setCampos dbCampos(tpa)
    orset.setTablas Array(tpa)
End Sub
Private Sub Class_Terminate()
    Set orset = Nothing
End Sub
' Generic Data management methods
Public Sub consulta()
    orset.consulta
End Sub
Public Sub consultaDatos(codig As String)
    orset.consulta Array(tpa_id & "=" & codig)
End Sub
Private Sub Reload_members()
    With orset
        codigo = .getDato(tpa_id)
        tipo = .getDato(tpa_tipo)
        descripcion = .getDato(tpa_descripcion)
        documentos = .getDato(tpa_documentos)
    End With
    RaiseEvent DataChanged
End Sub

Public Sub Nuevo(newtipo As String, newDescripcion As String, newDocumentos As Integer)
    orset.sInsert Array("", newtipo, newDescripcion, newDocumentos)
End Sub
Public Sub Modificar(codig As String, newtipo As String, newDescripcion As String, newDocumentos As Integer)
    orset.sUpdate Array(codig, newtipo, newDescripcion, newDocumentos)
End Sub
Public Sub Borrar(codig As String)
    orset.sDelete Array(tpa_id & "=" & codig)
End Sub
' Class methods
Public Sub llenaCombo(cajaCombo As ComboBox, conCodigo As Boolean)
    Dim i As Integer
    Me.consulta
    i = 0
    cajaCombo.Clear
    If conCodigo Then
        While orset.CanMoveNext
            cajaCombo.AddItem codigo & " - " & tipo
            cajaCombo.ItemData(i) = codigo
            orset.MoveNext
            i = i + 1
        Wend
    Else
        While orset.CanMoveNext
            cajaCombo.AddItem tipo
            cajaCombo.ItemData(i) = codigo
            orset.MoveNext
            i = i + 1
        Wend
    End If
    If cajaCombo.ListCount > 0 Then
        'si solo hay un precio lo selecciona
        cajaCombo.ListIndex = 0
    End If
End Sub
Public Sub llenaList(cajaCombo As ListBox, conCodigo As Boolean)
    Dim i As Integer
    Me.consulta
    i = 0
    cajaCombo.Clear
    If conCodigo Then
        While orset.CanMoveNext
            cajaCombo.AddItem arreglanum2dig(Me.codigo) & " - " & tipo
            cajaCombo.ItemData(i) = codigo
            orset.MoveNext
            i = i + 1
        Wend
    Else
        While orset.CanMoveNext
            cajaCombo.AddItem tipo
            cajaCombo.ItemData(i) = codigo
            orset.MoveNext
            i = i + 1
        Wend
    End If
    'If cajaCombo.ListCount = 1 Then
    '    cajaCombo.ListIndex = 0
    'End If
End Sub
Public Sub llenaHGrid(Grid As MSHFlexGrid, Optional anchos As Variant, Optional titulos As Variant)
    Dim i As Integer
    With Grid
    'vacia el grid
        .Clear
    'setea numero de columnas y filas
        .Cols = 4
        .Rows = 2
    'coloca datos
        Me.consulta
        If orset.numRegistros > 0 Then
            Set .DataSource = orset.mrec
        End If
        orset.CierraRec
    'setea anchos
        If IsMissing(anchos) Then
            .ColWidth(0) = 40 * 15
            .ColWidth(1) = 75 * 15
            .ColWidth(2) = 150 * 15
            .ColWidth(3) = 40 * 15
        Else
            'jala anchos de la variable
            cambiaAnchosHFG Grid, anchos
        End If
    'coloca titulos
        If IsMissing(titulos) Then
            .TextMatrix(0, 0) = "Codigo"
            .TextMatrix(0, 1) = "Tipo"
            .TextMatrix(0, 2) = "Descripcion"
            .TextMatrix(0, 3) = "Doc.Extras"
        Else
            'jala titulos de la variable
            cambiaTitulosHFG Grid, titulos
        End If
        .Row = 1
    End With
End Sub
Private Sub orset_DataChanged()
    Reload_members
End Sub
